package com.huanwei.mainfragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.huanwei.cc.R;
import com.huanwei.cc.activity.Me_data_activity;
import com.huanwei.cc.activity.Me_feedback_activity;
import com.huanwei.cc.activity.Me_set_activity;
import com.huanwei.cc.utils.SpfUtils;
import com.huanwei.note.Notebook_Activity;

import butterknife.ButterKnife;

/**
 * Created by zhuwenhai on 2017/12/1.
 * 首页-我的
 */

    public class Mine4Fragment extends Fragment implements View.OnClickListener {
    private LinearLayout me_fragment_follow, me_fragment_Fans, me_fragement_share, me_fragmen_business, me_fragmen_Recommend, me_fragmen_drafts, me_fragmen_Task, me_fragmen_Shopping, me_fragmen_set, me_fragment_Feedback, me_fragmen_wallet, me_fragmen_Record, me_fragmen_Order;
    private RelativeLayout me_fragment_data;
    View view;

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if (view == null) {
            view = View.inflate(getActivity(), R.layout.mine_fragment, null);
            ButterKnife.bind(this, view);
            initViewsAndEvents();
        }
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null) {
            parent.removeView(view);
        }

        return view;
    }



    TextView name;
    protected void initViewsAndEvents() {
        String names = (String) SpfUtils.get(getActivity(), "name", "");
        name = (TextView) view.findViewById(R.id.name);//设置
        name.setText(names);
        me_fragmen_set = (LinearLayout) view.findViewById(R.id.me_fragmen_set);//设置
        me_fragmen_set.setOnClickListener(this);
        me_fragment_Feedback = (LinearLayout) view.findViewById(R.id.me_fragment_Feedback);//反馈
        me_fragment_Feedback.setOnClickListener(this);
        me_fragmen_wallet = (LinearLayout) view.findViewById(R.id.me_fragmen_wallet);//钱包
        me_fragmen_wallet.setOnClickListener(this);
        me_fragmen_Record = (LinearLayout) view.findViewById(R.id.me_fragmen_Record);//记录
        me_fragmen_Record.setOnClickListener(this);
        me_fragmen_Order = (LinearLayout) view.findViewById(R.id.me_fragmen_Order);//订单
        me_fragmen_Order.setOnClickListener(this);
        me_fragmen_Shopping = (LinearLayout) view.findViewById(R.id.me_fragmen_Shopping);//购物车
        me_fragmen_Shopping.setOnClickListener(this);
        me_fragmen_Task = (LinearLayout) view.findViewById(R.id.me_fragmen_Task);//任务中心
        me_fragmen_Task.setOnClickListener(this);
        me_fragmen_drafts = (LinearLayout) view.findViewById(R.id.me_fragmen_drafts);//草稿箱
        me_fragmen_drafts.setOnClickListener(this);
        me_fragmen_Recommend = (LinearLayout) view.findViewById(R.id.me_fragmen_Recommend);//推荐
        me_fragmen_Recommend.setOnClickListener(this);
        me_fragmen_business = (LinearLayout) view.findViewById(R.id.me_fragmen_business);//商家入驻
        me_fragmen_business.setOnClickListener(this);
        me_fragement_share = (LinearLayout) view.findViewById(R.id.me_fragement_share);//分享
        me_fragement_share.setOnClickListener(this);
        me_fragment_Fans = (LinearLayout) view.findViewById(R.id.me_fragment_Fans);//粉丝
        me_fragment_Fans.setOnClickListener(this);
        me_fragment_follow = (LinearLayout) view.findViewById(R.id.me_fragment_follow);//关注
        me_fragment_follow.setOnClickListener(this);
        me_fragment_data = (RelativeLayout) view.findViewById(R.id.me_fragment_data);//个人资料
        me_fragment_data.setOnClickListener(this);
    }



    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.me_fragmen_set:
                startActivity(new Intent(getContext(), Me_set_activity.class));
                break;
            case R.id.me_fragment_Feedback:
                startActivity(new Intent(getContext(), Me_feedback_activity.class));
                break;

            case R.id.me_fragmen_Order:
                //我的问题
//                startActivity(new Intent(getContext(), Me_Wenti_activity.class));
//                startActivity(new Intent(getContext(), QQActivity.class));
                break;


            case R.id.me_fragment_data:
                startActivity(new Intent(getContext(), Me_data_activity.class));
                break;
            case R.id.me_fragmen_Shopping:
                startActivity(new Intent(getContext(), Notebook_Activity.class));
                break;


        }
    }
}
